﻿<?php
session_start();
if (!isset($_SESSION['usuario'])) {
    header('Location: ../viewer/vLogin.php');
}

include_once '../db/DBConnection.php';
DataBase::createConection();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <?php require("../viewer/vLayoutHead.php"); ?>
    </head>
    <body>

        <?php require("../viewer/vLayoutBody.php"); ?>

        <?php
        $serial = $_GET['serial'];
        $res = mysql_query("SELECT * FROM `produtos` WHERE `serial`= $serial");
        $res = mysql_fetch_array($res);

        $nome = $res[1];
        $descricao = $res[2];
        $preco = $res[3];
        ?>

        <div id="side-col">
            <br></br>
            <form name="edicaoProdutos" action="../controller/cEdicaoProdutos.php?serial=<?php echo $serial ?>" method="POST" enctype="multipart/form-data">
                <p>Nome: <input type="text" value="<?php echo $nome ?>" id="nome" name="nome" size="30" maxlength="100" required/></p>
                <p>Descrição: <textarea id="descricao" style="resize: none;" name="descricao" size="280" maxlength="1200" cols="45" rows="10" required><?php echo $descricao ?></textarea></p>
                <p>Preço: <input type="text" value="<?php echo $preco ?>" id="preco" name="preco" size="5" maxlength="5" required/></p>
                <p>Imagem:<input type="file" id="file" name="file"/></p>
                <!--<p><strong>(caso nenhuma imagem seja adicionada, ela não será alterada)</strong></p>-->

                <p><input type="submit" class="button black" value="Atualizar"/>
            </form>
            <a href="../viewer/vIndex.php" class="button black">Voltar</a></p>
            <br></br><br></br>
        </div>
    </body>
    <footer>
        <?php require("../viewer/vLayoutFooter.php"); ?>
    </footer>
</html>